home *** CD-ROM | disk | FTP | other *** search
Wrap
property myTimeOut, myRes, myDepth, myXRes, myYRes, myTimeUnit, myTimeOutFrame, myImmediateJump, myStartFrame, myStartTicks, myEndFrame global scrWidth, scrHeight, scrDepth on beginSprite me Initialize(me) end on exitFrame me CheckTimeOut(me) end on enterFrame me if the platform contains "Windows,32" then case myRes of "640x480": myXRes = 640 myYRes = 480 "800x600": myXRes = 800 myYRes = 600 "1024x768": myXRes = 1024 myYRes = 768 end case if (scrWidth = baScreenInfo("width")) and (scrHeight = baScreenInfo("height")) and (scrDepth = baScreenInfo("depth")) then Ok = baSetDisplay(myXRes, myYRes, myDepth, "temp", 0) else go(the frame + 1) end if end if end on Initialize me thisSprite = sprite(the currentSpriteNum) myStartFrame = thisSprite.startFrame myEndFrame = thisSprite.endFrame if symbolp(myTimeOutFrame) then case myTimeOutFrame of #previous: jumpToFrame = marker(-1) #loop: jumpToFrame = marker(0) #next: jumpToFrame = marker(1) end case else jumpToFrame = marker(myTimeOutFrame) end if myStartTicks = the ticks case myTimeUnit of "Seconds": myTimeOut = myTimeOut * 60 "Minutes": myTimeOut = myTimeOut * 60 * 60 "Hours": myTimeOut = myTimeOut * 60 * 60 * 60 end case myTimeOut = myTimeOut + myStartTicks myTimeOutFrame = jumpToFrame myImmediateJump = myImmediateJump = "jump immediately" end on CheckTimeOut me if the ticks > myTimeOut then if myImmediateJump or (the frame = myEndFrame) then go(myTimeOutFrame) end if else if the frame = myEndFrame then go(myStartFrame) end if end if end on substituteStrings me, parentString, childStringList i = childStringList.count() repeat while i tempString = EMPTY dummyString = childStringList.getPropAt(i) replacement = childStringList[i] lengthAdjust = dummyString.char.count - 1 repeat while 1 position = offset(dummyString, parentString) if not position then parentString = tempString & parentString exit repeat next repeat end if if position <> 1 then tempString = tempString & parentString.char[1..position - 1] end if tempString = tempString & replacement delete parentString.char[1..position + lengthAdjust] end repeat i = i - 1 end repeat return parentString end on ErrorAlert me, theError, Data behaviorName = string(me) delete word 1 of behaviorName delete char -30001 of behaviorName delete char -30001 of behaviorName case theError of #invalidChannel: if the runMode = "Author" then terror1 = "BEHAVIOR ERROR: Frame ^0, Sprite ^1" terror1 = substituteStrings(me, terror1, ["^0": the frame, "^1": the currentSpriteNum]) terror2 = "Behavior ^0 should be attached to the frame script channel." terror2 = substituteStrings(me, terror2, ["^0": behaviorName]) terror3 = "Current Channel = ^0" terror3 = substituteStrings(me, terror3, ["^0": Data]) alert(terror1 & RETURN & RETURN & terror2 & RETURN & RETURN & terror3) abort() end if #missingMarker: if the runMode = "Author" then terror1 = "BEHAVIOR ERROR: Frame ^0, Sprite ^1" terror1 = substituteStrings(me, terror1, ["^0": the frame, "^1": the currentSpriteNum]) terror2 = "Frame behavior ^0 is set to jump to marker ^1. " & "This marker cannot be found. " & " Choose a valid marker in the Behavior Parameters dialog." terror2 = substituteStrings(me, terror2, ["^0": behaviorName, "^1": myTimeOutFrame]) terror3 = "In the meantime, frame ^0 will be used instead." terror3 = substituteStrings(me, terror3, ["^0": Data]) alert(terror1 & RETURN & RETURN & terror2 & RETURN & RETURN & terror3) end if #endlessLoop: if the runMode = "Author" then if symbolp(myTimeOutFrame) then case myTimeOutFrame of #previous: jumpToFrame = marker(-1) #loop: jumpToFrame = marker(0) #next: jumpToFrame = marker(1) end case else jumpToFrame = marker(myTimeOutFrame) end if terror1 = "BEHAVIOR ERROR: Frame ^0, Sprite ^1" terror1 = substituteStrings(me, terror1, ["^0": the frame, "^1": the currentSpriteNum]) terror2 = "Frame behavior ^0 is set to jump to marker ^1 (frame ^2 ). " & " This is within the span of the behavior and will cause an endless loop." terror2 = substituteStrings(me, terror2, ["^0": behaviorName, "^1": myTimeOutFrame, "^2": jumpToFrame]) terror3 = "Frame ^0 will be used instead." terror3 = substituteStrings(me, terror3, ["^0": Data]) alert(terror1 & RETURN & RETURN & terror2 & RETURN & RETURN & terror3) end if end case end on isOKToAttach me, aSpriteType, aSpriteNum tisok = 0 if aSpriteType = #script then tisok = 1 end if return tisok end on getPropertyDescriptionList me nextMarker = nextMarker(me) return [#myRes: [#comment: "Change Resolution to", #format: #string, #range: ["640x480", "800x600", "1024x768"], #default: "800x600"], #myDepth: [#comment: "Colour Depth", #format: #integer, #range: ["8", "16", "24"], #default: "16"], #myTimeOut: [#comment: "Loop over selected frames for...", #format: #integer, #range: [#min: 1, #max: 120], #default: 30], #myTimeUnit: [#comment: EMPTY, #format: #string, #range: ["Ticks", "Seconds", "Minutes", "Hours"], #default: "Seconds"], #myTimeOutFrame: [#comment: "... " & "then jump to marker", #format: #marker, #default: nextMarker], #myImmediateJump: [#comment: "When the time is up", #format: #string, #range: ["complete the loop", "jump immediately"], #default: "jump immediately"]] end on nextMarker me labelString = the labelList delete char -30000 of labelString markerCount = the number of lines in labelString theFrame = the frame repeat with i = 1 to markerCount theMarker = line i of labelString markerFrame = marker(theMarker) if theFrame < markerFrame then return theMarker end if end repeat end